[URGENT HELP]409 Conflict on creating multiple event rules

I need help with an error message that I’m getting when trying to create event rules on service.

I’m calling the https://api.pagerduty.com/services/id/rules POST method in a for loop. I want to create multiple event rules but it only works once and creates one rules and then gives me the following error:

Body { url: ‘https://api.pagerduty.com/services/XXXXX/rules’, status: 409, statusText: ‘Conflict’, headers: Headers { _headers: { server: [Array], date: [Array], ‘content-type’: [Array], ‘content-length’: [Array], connection: [Array], ‘access-control-allow-origin’: [Array], ‘cache-control’: [Array], ‘x-request-id’: [Array] } }, ok: false, body: PassThrough { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: [Object], tail: [Object], length: 1 }, length: 40, pipes: null, pipesCount: 0, flowing: null, ended: true, endEmitted: false, reading: false, sync: false, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, paused: true, emitClose: true, autoDestroy: false, destroyed: false, defaultEncoding: ‘utf8’, awaitDrain: 0, readingMore: false, decoder: null, encoding: null }, readable: true, domain: Domain { domain: null, _events: [Object], _eventsCount: 3, _maxListeners: undefined, members: [], [Symbol(kWeak)]: WeakReference {} }, _events: [Object: null prototype] { prefinish: [Function: prefinish] }, _eventsCount: 1, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: true, ended: true, finished: true, destroyed: false, decodeStrings: true, defaultEncoding: ‘utf8’, length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: true, errorEmitted: false, emitClose: true, autoDestroy: false, bufferedRequestCount: 0, corkedRequestsFree: [Object] }, writable: false, allowHalfOpen: true, _transformState: { afterTransform: [Function: bound afterTransform], needTransform: false, transforming: false, writecb: null, writechunk: null, writeencoding: ‘buffer’ } }, bodyUsed: false, size: 0, timeout: 0, _raw: [], _abort: false }

I have no idea how to resolve this as I can see that the 409 means that there is something wrong with the server.

Am I making the requests too fast?

I need urgent assistance with this as a huge company project is dependant on this automated creation of event rules.

Regards

Suggest you break this down and try to get one rule successfully created to ensure your script and API use is correct. Then add in the additional logic for looping through and adding multiple rules. If you’re confident with that, then maybe share the actual script and POST you’re sending in (redacted as needed).